package net.wanho.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * Ajax响应结果对象
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult implements Serializable {
    // 响应状态码
    private Integer status;

    // 响应消息
    private String msg;

    // 响应数据
    private Object data;

    public static AjaxResult success(Integer status, String msg, Object data){
        return new AjaxResult(status, msg, data);
    }

    public static AjaxResult success(Integer status, String msg){
        return new AjaxResult(status, msg, null);
    }

    public static AjaxResult success(Integer status){
        return new AjaxResult(status, "success", null);
    }

    public static AjaxResult success(){
        return new AjaxResult(200, "success", null);
    }

    public static AjaxResult fail(Integer status, String msg){
        return new AjaxResult(status, msg, null);
    }

    public static AjaxResult fail(String msg){
        return new AjaxResult(500, msg, null);
    }
}
